﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Web.Configuration;
using System.Data.Common;
using Common;


namespace DataAccess
{
    public class ConnectionClass
    {
        public ElectrosLtdEntities Entity { get; set; }
        
        public DbTransaction Transaction { get; set; }

        public ConnectionClass()
        {
            Entity = new ElectrosLtdEntities();
        }

        public ConnectionClass(bool isAdmin)
        {
            //add 2 references System.Configuration, System.Web by right click on DataAccess, add reference
            string connectionString = "";
            if (isAdmin)
            {
                connectionString = WebConfigurationManager.ConnectionStrings["ElectrosLtdEntities"].ConnectionString;
            }
            else
            {
                //make use of the connection string of users/guests
                connectionString = WebConfigurationManager.ConnectionStrings["ElectrosLtdEntities"].ConnectionString;
            }

            Entity = new ElectrosLtdEntities(connectionString);

            
        }
    }
}



